using MicroMsg.Common.Utils;
using MicroMsg.Manager;
using Microsoft.Phone.Controls;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.UserContrl
{
	public class MMReaderItemCtrl : UserControl
	{
		public delegate void ListItemClick(object sender, object object_0);
		private const string TAG = "MMReaderItemCtrl";
		private SnsHttpImgCtrlBase imgDownLoader = new SnsHttpImgCtrlBase();
		public static DependencyProperty ItemObjectProperty = DependencyProperty.Register("ItemObject", typeof(MMReaderItem), typeof(MMReaderItemCtrl), new PropertyMetadata(null, new PropertyChangedCallback(MMReaderItemCtrl.OnItemObjectPropertyChanged)));
		private bool mBIsFirstLoaded = true;
		internal Button btnLayoutRoot;
		internal TextBlock txtContent;
		internal MMHttpImg imgCover;
		private bool _contentLoaded;
		public event MMReaderItemCtrl.ListItemClick ItemClick;
		public MMReaderItem ItemObject
		{
			get
			{
				return (MMReaderItem)base.GetValue(MMReaderItemCtrl.ItemObjectProperty);
			}
			set
			{
				base.SetValue(MMReaderItemCtrl.ItemObjectProperty, value);
			}
		}
		public MMReaderItemCtrl()
		{
			this.InitializeComponent();
			this.imgCover.imgContent.set_Stretch(3);
			base.SetValue(TiltEffect.IsTiltEnabledProperty, true);
			this.imgCover.imgContent.set_Stretch(3);
			base.add_Loaded(new RoutedEventHandler(this.Control_Loaded));
			base.add_Unloaded(new RoutedEventHandler(this.Control_Unloaded));
			ShowObjectInMemory.AddOneObjectRecord(this);
		}
		~MMReaderItemCtrl()
		{
			ShowObjectInMemory.RemoveOneObjectRecord(this);
		}
		private static void OnItemObjectPropertyChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_Property() == MMReaderItemCtrl.ItemObjectProperty)
			{
				(dependencyObject_0 as MMReaderItemCtrl).ItemObjectPropertyChanged(dependencyPropertyChangedEventArgs_0);
			}
		}
		private void ItemObjectPropertyChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			if (dependencyPropertyChangedEventArgs_0.get_OldValue() != dependencyPropertyChangedEventArgs_0.get_NewValue())
			{
				this.RefreshItem();
			}
		}
		private void Control_Loaded(object sender, RoutedEventArgs e)
		{
		}
		private void Control_Unloaded(object sender, RoutedEventArgs e)
		{
		}
		private void btnLayoutRoot_mClicked(object sender, object object_0)
		{
			if (this.ItemClick != null)
			{
				this.ItemClick(this, this.ItemObject);
			}
		}
		private void RefreshItem()
		{
			this.imgCover.imgContent.set_Source(null);
			this.txtContent.set_Text("");
			if (this.ItemObject == null)
			{
				return;
			}
			this.txtContent.set_Text(this.ItemObject.title);
			this.imgCover.SetUrl(this.ItemObject.cover);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Chat/MultyPicArticleMsg/MMReaderItemCtrl.xaml", 2));
			this.btnLayoutRoot = (Button)base.FindName("btnLayoutRoot");
			this.txtContent = (TextBlock)base.FindName("txtContent");
			this.imgCover = (MMHttpImg)base.FindName("imgCover");
		}
	}
}
